package net.fdukedom.epicurus.core.extensions.menu;

import net.fdukedom.epicurus.resource.ResourceDispatcher;

import java.util.HashMap;
import java.util.Map;

/**
 * Adds Register item to menu
 *
 * @author Dmitry Y. Kochelaev
 */
public class RegisterExtension extends MenuExtensionHandler {

    private ResourceDispatcher resourceDispatcher = ResourceDispatcher.getInstance();

    private String registerTitle = resourceDispatcher.getBundledValue("bundles.core.Extensions", "core.register.title");

    private String registerLink = resourceDispatcher.getBundledValue("bundles.core.Extensions", "core.register.actionLink");

    public Map<String, Object> execute(Map<String, Object> parameters) {
        Map<String, Object> result = new HashMap<String, Object>();
        Boolean isVisible = !((Boolean) parameters.get("isLoggedIn"));
        result.put(IS_EXTENSION_VISIBLE, isVisible);
        if (isVisible) {
            result.put(EXTENSION_TITLE, registerTitle);
            result.put(EXTENSION_ACTION, registerLink);
        }
        return result;
    }

    public String getPresentation() {
        return "";
    }
}
